// JavaScript Document
var adsImages = new Array();
var adsTimers = new Array();
var adsUrls = new Array();
var adsContainer = null;
var adsCurrentIndex;

function addAdToQueque(img, sec, url)
{
	adsImages.push(img);
	adsTimers.push(sec*1000);
	adsUrls.push(url);
}

function setAdsContainer(divID)
{
	adsContainer = document.getElementById(divID);
}

function printCurrentAd()
{
	if(adsUrls[adsCurrentIndex] && trim(adsUrls[adsCurrentIndex]).length)
		adsContainer.innerHTML = '<a href="'+adsUrls[adsCurrentIndex]+'" target="_blank"><img src="'+adsImages[adsCurrentIndex]+'" style="max-height:600px; max-width:120px;" /></a>';
	else
		adsContainer.innerHTML = '<img src="'+adsImages[adsCurrentIndex]+'" style="max-height:600px; max-width:120px;" />';
	setTimeout("adsNext();",adsTimers[adsCurrentIndex]);
}

function adsStart()
{
	adsCurrentIndex = 0;
	printCurrentAd();
}

function adsNext()
{
	adsCurrentIndex++;
	if(adsCurrentIndex == adsImages.length)
		adsCurrentIndex = 0;
	printCurrentAd();
}
